﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MedicalAdviser.Portable.DataTypes.WsTypes;
using MedicalAdviser.Portable.DataTypes;
namespace MedicalAdviser.DAL
{
    public class DbInserts
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="tInput"></param>
        /// <returns></returns>
        public static int SaveSearchKeyWord(AppInteration tInput)
        {
            try
            {
                return DrugContext.Context().spInsert_SearchKeyword(tInput.ClientAuth.AccessToken, tInput.StrDescription);
            }
            catch (Exception ex)
            {
                Loggin.Loggin.LOGGER.WriteEvent(
                   "MedicalAdviser.DAL.DbInserts.DbInserts.SaveSearchKeyWord"
                   , ex, Loggin.LogginType.Error);

                throw ex;
            }
        }

        /// <summary>
        /// Guardar as recomendações de um utilizador para um medicamento;
        /// </summary>
        /// <param name="tInput"></param>
        /// <returns></returns>
        public static int SaveUserRecommendation(AppInteration tInput)
        {
            try
            {
                return DrugContext.Context().spInsert_Recommendation( tInput.ClientAuth.AccessToken  ,tInput.Drug.CodEmbalagem, tInput.Drug.CodMedicamento,tInput.Rate);
            }
            catch (Exception ex)
            {
                Loggin.Loggin.LOGGER.WriteEvent(
                   "MedicalAdviser.DAL.DbInserts.DbInserts.SaveUserRecommendation"
                   , ex, Loggin.LogginType.Error);

                throw ex;
            }
        }

        /// <summary>
        /// Vou guardar a informação que um user abriu um medicamento,
        /// nao vou associar ao user mas apenas a sua idade
        /// </summary>
        /// <param name="tInput"></param>
        /// <returns></returns>
        public static int MarkViewDrug(AppInteration tInput )
        {
            try
            {
                return DrugContext.Context().spInser_ViewMedicamento(tInput.Drug.CodEmbalagem, tInput.Drug.CodMedicamento);
            }
            catch (Exception ex)
            {
                Loggin.Loggin.LOGGER.WriteEvent(
                   "MedicalAdviser.DAL.DbInserts.DbInserts.MarkViewDrug"
                   , ex, Loggin.LogginType.Error);

                throw ex;
            }
        }


    }
}
